from django.contrib import admin
from .models import KnowledgeNode, LearningPath, PathNode, StudyRecord, ReviewTask


@admin.register(KnowledgeNode)
class KnowledgeNodeAdmin(admin.ModelAdmin):
    list_display = ['name', 'user', 'node_type', 'difficulty_level', 'mastery_level', 'created_at']
    list_filter = ['node_type', 'difficulty_level', 'user']
    search_fields = ['name', 'description']
    filter_horizontal = ['prerequisites', 'documents']


@admin.register(LearningPath)
class LearningPathAdmin(admin.ModelAdmin):
    list_display = ['title', 'user', 'target_node', 'status', 'progress', 'created_at']
    list_filter = ['status', 'user']
    search_fields = ['title', 'description']
    date_hierarchy = 'created_at'


@admin.register(PathNode)
class PathNodeAdmin(admin.ModelAdmin):
    list_display = ['path', 'node', 'order', 'status', 'progress']
    list_filter = ['status', 'path']
    search_fields = ['path__title', 'node__name']


@admin.register(StudyRecord)
class StudyRecordAdmin(admin.ModelAdmin):
    list_display = ['user', 'node', 'duration_minutes', 'created_at']
    list_filter = ['user', 'created_at']
    search_fields = ['user__username', 'node__name', 'notes']
    date_hierarchy = 'created_at'


@admin.register(ReviewTask)
class ReviewTaskAdmin(admin.ModelAdmin):
    list_display = ['user', 'node', 'scheduled_date', 'status', 'completed_at']
    list_filter = ['status', 'scheduled_date', 'user']
    search_fields = ['user__username', 'node__name']
    date_hierarchy = 'scheduled_date'
